﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>登录页面</title>
    <meta name="description" content="" />
    <meta name="keywords" content="index" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="~/Content/assets/i/favicon.png" />
    <link rel="stylesheet" href="~/Content/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="~/Content/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="~/Content/assets/css/app.css" />
    <script src="~/Content/assets/js/jquery.min.js"></script>

</head>

<body onkeydown="on_return(event);" data-type="login" style="background-image:url('../../Content/assets/img/bg.jpg');background-attachment: fixed;background-repeat: no-repeat;background-size: cover;">
    <script src="~/Content/assets/js/theme.js"></script>
    <div class="bg-blue-300" >
        <!-- 风格切换 -->
        <div>
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <center>
                <img src="~/Content/assets/img/logo.png" width="300px" height="100px" />
                <br/>
                <span style="color:white;font-family:'Microsoft YaHei';font-size:30px;font-weight:bold">
                    @ViewBag.AppTitle
                </span>
            </center>
        </div>
        <div class="tpl-login">
            <div class="tpl-login-content">
                <form class="am-form tpl-form-line-form">
                    <div class="am-form-group">
                        <input type="text" class="tpl-form-input" id="user-name" placeholder="@ViewBag.Text1" />
                    </div>
                    <div class="am-form-group">
                        <input type="password" class="tpl-form-input" id="user-pwd" placeholder="@ViewBag.Text2" />
                    </div>
                    <div class="am-form-group">
                        <table style="width:100%">
                            <tr>
                                <td><button type="button" class="am-btn am-btn-primary  am-btn-block btn-success  tpl-login-btn" onclick="login()">@ViewBag.Text3</button></td>
                            </tr>
                        </table>
                    </div>
                    <br />
                    <div class="loginbm" style="text-align:center"><span style="color:white;font-size:9px">@ViewBag.Text4</span></div>
                    <div class="loginbm" style="text-align:center"><span style="color:white;font-size:9px">@ViewBag.Text5</span></div>
                </form>
            </div>
        </div>

    </div>
   
    <script src="~/Content/assets/js/amazeui.min.js"></script>
    <script src="~/Content/assets/js/app.js"></script>
    <script>

        function on_return(event) {
            if (event.keyCode == 13) {
                login();
            }
        }

        function login() {
            //判断输入密码的类型
            function CharMode(iN) {
                if (iN >= 48 && iN <= 57) //数字
                    return 1;
                if (iN >= 65 && iN <= 90) //大写
                    return 2;
                if (iN >= 97 && iN <= 122) //小写
                    return 4;
                else
                    return 8;
            }
            //bitTotal函数
            //计算密码模式
            function bitTotal(num) {
                modes = 0;
                for (i = 0; i < 4; i++) {
                    if (num & 1) modes++;
                    num >>>= 1;
                }
                return modes;
            }
            //返回强度级别
            function checkStrong(sPW) {
                if (sPW.length < 8)
                    return 0; //密码太短，不检测级别
                Modes = 0;
                for (i = 0; i < sPW.length; i++) {
                    //密码模式
                    Modes |= CharMode(sPW.charCodeAt(i));
                }
                return bitTotal(Modes);
            }

            var name = $("#user-name").val();
            var pwd = $("#user-pwd").val();
                if (name == "" || pwd == "") {
                    alert('@ViewBag.Text6');
                }
                else {
                    $.ajax({
                        url: '/Login/UserLogin',
                        dataType: 'text',
                        type: 'post',
                        data: { name: name, pwd: pwd},
                        success: function (data) {
                            if (data == 'true') {
                                if (pwd == "123456")
                                    window.location.href = "/Main/ChangePwd";
                                else if(checkStrong(pwd)<3)
                                    window.location.href = "/Main/ChangePwd?type=1";
                                else
                                    window.location.href = "/Main/Index";
                            }
                            else
                                alert(data);
                               // $.messager.alert('提示！', data, 'info');
                        }
                    });
                }

        }
    </script>
</body>

</html>